import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0

Item {
    id:root
    width: 850
    height: 580
    property real minSize:  Math.min(width/850, height/580)


//    signal qmlSN_sqlWriteFinish()
//    onQmlSN_sqlWriteFinish: {

//    }
    onFocusChanged: {
        if(focus){
            text_aug.text = $sqlMcRecorder.qml_getFactor("motor_capacity")
            text_aig.text = $sqlMcRecorder.qml_getFactor("stator_voltage")
            text_aus.text = $sqlMcRecorder.qml_getFactor("stator_current")
            text_ail.text = $sqlMcRecorder.qml_getFactor("exc_capacity")
            text_atb.text = $sqlMcRecorder.qml_getFactor("exc_current")
            text_apq.text = $sqlMcRecorder.qml_getFactor("motor_id")
        }
    }

    Rectangle {
        id: rectangle
        y: 30*root.minSize
        width: 600*root.minSize
        height: 450*root.minSize
        color: "#6692e8bc"
        radius: 10*root.minSize
        anchors.horizontalCenter: parent.horizontalCenter

        ColumnLayout {
            x: 0
            width: parent.width*0.55
            height: parent.height*0.9
            anchors.top: parent.top
            property real textSize: 30*root.minSize

            Text {
                text: qsTr("发电机额定容量:")
                color: "#44fdfd"
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
                font.pixelSize: parent.textSize
            }

            Text {
                text: qsTr("发电机额定电压:")
                color: "#44fdfd"
                font.pixelSize: parent.textSize
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
            }

            Text {
                text: qsTr("发电机额定定子电流:")
                color: "#44fdfd"
                font.pixelSize: parent.textSize
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
            }

            Text {
                text: qsTr("额定励磁电压:")
                color: "#44fdfd"
                font.pixelSize: parent.textSize
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
            }

            Text {
                text: qsTr("额定励磁电流:")
                color: "#44fdfd"
                font.pixelSize: parent.textSize
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
            }

            Text {
                text: qsTr("机组编号:")
                color: "#44fdfd"
                font.pixelSize: parent.textSize
                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
            }
        }

        ColumnLayout {
            x: parent.width*0.58
            width: parent.width*0.35
            height: parent.height*0.9
            anchors.top: parent.top
            property real textSize: 30*root.minSize

            TextInput {
                id: text_aug
                color: "#FFFFFF"
                text: "666670"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                font.pixelSize: parent.textSize
                Text {
                    text: "KVA"
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("motor_capacity", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("motor_capacity"))
                }
            }

            TextInput {
                id: text_aig
                color: "#FFFFFF"
                text: "18000"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                font.pixelSize: parent.textSize
                Text {
                    text: "V"
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("stator_voltage", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("stator_voltage"))
                }
            }

            TextInput {
                id: text_aus
                color: "#FFFFFF"
                text: "21384"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                font.pixelSize: parent.textSize
                Text {
                    text: "A"
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("stator_current", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("stator_current"))
                }
            }

            TextInput {
                id: text_ail
                color: "#FFFFFF"
                text: "318"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                font.pixelSize: parent.textSize
                Text {
                    text: "V"
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("exc_capacity", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("exc_capacity"))
                }
            }

            TextInput {
                id: text_atb
                color: "#FFFFFF"
                text: "2709"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                font.pixelSize: parent.textSize
                Text {
                    text: "A"
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("exc_current", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("exc_current"))
                }
            }

            TextInput {
                id: text_apq
                color: "#FFFFFF"
                validator: RegExpValidator{regExp:/[0-9]+/}
                selectByMouse: true
                text: qsTr("1")
                font.pixelSize: parent.textSize
                Text {
                    text: qsTr("号机")
                    color: "#44fdfd"
                    anchors.left: parent.right
                    font.pixelSize: parent.parent.textSize
                }
                onTextChanged: {
                    $sqlMcRecorder.qml_setMotorFactor("motor_id", Number(text))
                    if($sqlMcRecorder.qml_getPrintFlag()) console.log($sqlMcRecorder.qml_getFactor("motor_id"))
                }
            }
        }

        Text {
            id: element
            y: 420*root.minSize
            color: "#c3bf1e"
            text: qsTr("*本页参数更改后自动保存")
            anchors.horizontalCenter: parent.horizontalCenter
            font.pixelSize: 22*root.minSize
        }


    }

    EXC_Normal_BtnUncheckStyle {
        id: button3
        nameText: qsTr("返回")
        nameFontpixelSize: 30*Math.min(root.width/850, root.height/580)
        width: parent.width*0.15
        height: parent.height*0.09
        anchors.right: parent.right
        anchors.rightMargin: 10
        anchors.topMargin: parent.height*0.87
        anchors.top: parent.top
        onClicked: {
            sw.currentIndex = 0
        }
    }

}
